package ${basepackage}.framework.base.controller;

import java.beans.PropertyEditorSupport;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;

import ${basepackage}.framework.base.util.AppConstant;

import ${basepackage}.framework.base.util.AppConstant;

<#include "/author.include">
public class TimestampEditor extends PropertyEditorSupport {

	public String getAsText() {
		Timestamp value = (Timestamp) getValue();
		if (null == value) {
			return "";
		}
		SimpleDateFormat df = new SimpleDateFormat(
				AppConstant.DEFAULT_DATETIME_FORMAT);
		return df.format(value);
	}

	public void setAsText(String text) throws IllegalArgumentException {
		Timestamp value = null;
		if (null != text && !text.equals("")) {
			SimpleDateFormat df = new SimpleDateFormat(
					AppConstant.DEFAULT_DATETIME_FORMAT);
			try {
				value = new Timestamp(df.parse(text).getTime());
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		setValue(value);
	}
}